<template>
  <div>
    <el-form ref="form" :model="form" label-width="80px" style="width: 500px;">
      <el-form-item label="账号">
        <el-input v-model="form.username"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input type="password" v-model="form.password"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submit">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import md5 from 'js-md5'

export default {
  data() {
    return {
      form: {
        username: 'admin',
        password: 'zijy2019'
      },
    }
  },
  methods: {
    submit() {
      console.log('点击登录', this.form)
      // const form = this.form
      
      // 方法1 json类型转换
      // const form = JSON.parse(JSON.stringify(this.form))
      
      // 方法2 解构赋值
      const form = { ...this.form }
      
      form.password = md5(form.password)
      this.$emit('on-submit', form )
    },
  },
}
</script>

<style>
</style>
